<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
 	<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
</head>
<body>
<div class="container-fluid" id="main-container">
    <div id="page-content" class="clearfix">
        <div class="row-fluid">
            <div class="row-fluid">
                <!-- 检索  -->
                <div class="ibox-title" style="border-color: white;">
                    <div class="row">
                        <div class="col-sm-12">
                            <div class="form-group form-inline">
                                <span> 公司名称：</span>
								<input id="companyName" type="text" placeholder="请输入公司名称" class="input-sm form-control">
								<span> 岗位名称：</span>
								<input id="name" type="text" placeholder="请输入岗位名称" class="input-sm form-control">
								<span> 创建人：</span>
								<input type="text" class="input-sm form-control" id="userName" onclick="openTree('user');" placeholder="请选择创建人"
										readonly="readonly"  name="userName"/> 
								<input type="hidden" name="userId" id="userId" />
								 <a id="find_btn" type="button" class="btn btn-sm btn-primary"> 搜索</a> 
								 <a id="reset_btn" type="button" class="btn btn-sm btn-warning"> 重置</a>
	                            <s:hasPermission name="demandEnterprise:add">
	                             	<a class="btn btn-sm btn-success" onclick="showadd();"> 添加</a>
	                            </s:hasPermission>
							</div>
						</div>
                    </div>
                </div>
                <!-- biaogebigin -->
                <div class="ibox-content" style=" padding-left: 0px; margin-top: 10px;">
                    <div class="jqGrid_wrapper">
                        <table id="table_list"></table>
                        <div id="pager_list"></div>
                    </div>
                </div>
                <!-- tableover -->
            </div>
            <!-- PAGE CONTENT ENDS HERE -->

        </div>
        <!--/row-->
    </div>
    <!--/#page-content-->
</div>
<!--/.fluid-container#main-container-->
<script type="text/javascript">
    $(top.hangge());
        $.jgrid.defaults.styleUI = "Bootstrap";
        $("#table_list").jqGrid({
            url: '<%=contextPath%>/demandEnterprise/listData',
            datatype: "json",
            postData: {}, //发送数据
            autowidth: true,
            rownumbers: true,
            shrinkToFit: true,
            sortname: 'createDate',
            sortorder: "desc",
            mtype: "post",
            rowNum: 10,
            rowList: [10, 20, 30],
            colNames: [
			"id",
			"公司名称",
			"岗位名称",
			"岗位职能",
			"岗位产生原因",
			"工作区域",
			"汇报上级",
			"直接下属",
			"年龄区间",
			"最佳年龄",
			"性别",
			"学历",
			"薪酬范围",
			"薪酬结构",
			/* "对标企业经历",
			"排除企业工作的人", */
			/* "排除区域",
			" 备注 ", */
			"人选",
			"状态",
	        "操作"],
            colModel: [
			{name: "id",index: "id",hidden: true}, 
			{name:"company.name",index:"company.name",width:100},
			{name:"positionName",index:"positionName",width:100},
				{name:"positionNames",index:"positionNames",width:100},
				{name:"cause",index:"cause",width:100},
				{name:"workAreaNames",index:"workAreaNames",width:100},
				{name:"reportSuperiors",index:"reportSuperiors",width:100},
				{name:"underling",index:"underling",width:100},
				{name:"intervalAge",index:"intervalAge",width:100},
				{name:"optimalAge",index:"optimalAge",width:100},
				{name:"sex",index:"sex",width:50,
					formatter: function (value, options, row) {
						if(value == 0){
							return "不限";
						}
						if(value == 1){
							return "男";
						}
						if(value == 2){
							return "女";
						}
					}
				},
				{name:"education",index:"education",width:100},
				{name:"salary",index:"salary",width:100},
				{name:"salaryStructure",index:"salaryStructure",width:100},
				/* {name:"standardEnterprise",index:"standardEnterprise",width:100},
				{name:"excludePerson",index:"excludePerson",width:100}, */
				/* {name:"excludeAreaNames",index:"excludeAreaNames",width:100},
				{name:"remark",index:"remark",width:100}, */
				{name:"persons",index:"persons",width:50,
					formatter: function (value, options, row) {
						var htm="";
						if(value==0){
							htm ="0";
						}else {
							htm ='<a onclick="openresume(&quot;' + row.id + '&quot;,&quot;' + row.company.id + '&quot;);">'+value+'</a>';
						}
						return htm;
					}
				},
				{name:"dictStatus",index:"dictStatus",width:100,
					formatter: function (value, options, row) {
						var htm="";
							htm ='<a onclick="updateStatus(&quot;' + row.id + '&quot;);">'+value+'</a>';
						return htm;
					}
				},
	        {
                formatter: function (cellvalue, options, row) {
                    return " <s:hasPermission name="demandEnterprise:detail"><a class='btn btn-sm btn-info' title='查看' onclick='showeye(&quot;" + row.id + "&quot;)'><i class='icon-eye-open'></i></a></s:hasPermission> "
                          + " <s:hasPermission name="demandEnterprise:edit"><a class='btn btn-sm btn-warning' title='修改' onclick='showedit(&quot;" + row.id + "&quot;)'><i class='icon-edit'></i></a></s:hasPermission> "
                         + " <s:hasPermission name="demandEnterprise:delete"><a class='btn btn-sm btn-danger' title='删除' onclick='del(&quot;" + row.id + "&quot;)'><i class='icon-trash'></i></a></s:hasPermission> ";
                },
                width: 180
            }],
            height: $(window).height() - 170,
            pager: "#pager_list",
            multiselect: true,//多选按钮
            //multiboxonly: true,
            viewrecords: true,
            hidegrid: false
        });
        //表格自适应高宽
        $(window).bind("resize", function () {
            var b = $(".jqGrid_wrapper").width();
            $("#table_list").setGridWidth(b);
            $("#table_list").setGridHeight($(window).height() - 170);
        })
        $("#table_list").navGrid('#pager_list', {edit: false, add: false, del: false, search: false})
        /* 判断是否有添加权限 */
        //检索
        $("#find_btn").click(function () {
            var name = $("#name").val();
            var company_name = $("#companyName").val();
            var userId = $("#userId").val();
            $("#table_list").jqGrid('setGridParam', {
                postData: {
                	 'name': name,
                	 'companyName': company_name,
                	 'createuserid':userId
                	 }, //发送数据
                page: 1
            }).trigger("reloadGrid"); //重新载入
        });
        $("#reset_btn").click(function(){ 
        	$("#name").val('');
        	$("#companyName").val('');
        	$("#userId").val('');
        	$("#userName").val('');
		});

    //删除
    function del(id) {
        swalopen(id, "<%=contextPath%>/demandEnterprise/delete");
    };

    //查看
    function showeye(id) {
        window.open("<%=contextPath%>/demandEnterprise/detailView?id=" + id);
    }
  //修改
    function showedit(id) {
        openyem("修改需求", "<%=contextPath%>/demandEnterprise/editView?id=" + id+"&tops=0", 900, 850);
    }
    
  //添加
    function showadd(id) {
        openyem("添加需求", "<%=contextPath%>/demandEnterprise/addView?tops=0", 900, 850);
    }
  //查看简历人选
  function openresume(id,companyId) {
	  openyem("查看简历人选", "<%=contextPath%>/resume/listForProject?projectId="+id+"&companyId="+companyId, 900, 850);
   }
  function updateStatus(id) {
	  openyem("修改需求状态", "<%=contextPath%>/demandEnterprise/statusView?id=" + id, 500, 350);
 }
  function openTree(obj,types){
	     var ids = $("#"+obj+"Id").val();
	   	 var diag = new top.Dialog();
		 diag.Drag=true;
		 diag.Title ="请选择";
		 diag.URL = '<%=contextPath %>/'+obj+'/openZtree?ids='+ids+"&types=redio";
		 diag.Width = 250;
		 diag.Height = 400;
		 diag.CancelEvent = function(){ //关闭事件
			 var tempid = diag.innerFrame.contentWindow.document.getElementById('tempids').value;
			 var tempname = diag.innerFrame.contentWindow.document.getElementById('tempnames').value;
			if(tempid.length!==0){
				if(typeof(num)=="undefined"){ 
					$("#"+obj+"Id").val(tempid);
					$("#"+obj+"Name").val(tempname);
				}else{
					$("#"+obj+num+"Id").val(tempid);
					$("#"+obj+num+"Name").val(tempname);
				}
			}
			diag.close();
		 };
		 diag.show();
	}
</script>
</body>
</html>

